<?php

class SparringsellController extends \Base\AbstractController {

    /**
     * @desc 求大腿
     */
    public function listAction() {
        $request = $this->getRequest();
        $uid     = $request->get('uid');
        $page    = new \Lib\Paginator('sparringSell');
        $where   = [];

        if(!empty($uid)) {
            $where['uid'] = $uid;
        }

        $page->where($where);
        $this->assign('count', $page->count());
        $this->assign('page', $page->getPage());
        $this->assign('perPage', $page->getPerpage());
        $memberMapper = \Mapper\MemberModel::getInstance();
        $gameMapper   = \Mapper\SparringGameModel::getInstance();
        $models       = $page->lists();
        $return       = [];

        foreach($models as $model) {
            $data                     = $model->toArray();
            $data['member_nick_name'] = urldecode($memberMapper->findById($data['uid'])->getNick_name());
            $data['game_name']        = $gameMapper->findById($data['game_id'])->getGame_name();
            $return[]                 = $data;
        }

        $this->assign('lists', $return);

    }

    /**
     * @desc 详情
     */
    public function editAction() {

    }
}
